package org.ovirt.jenkins;

import hudson.Extension;
import hudson.model.Computer;
import hudson.model.Descriptor.FormException;
import hudson.model.Slave;
import hudson.slaves.NodeProperty;
import hudson.slaves.ComputerLauncher;
import hudson.slaves.RetentionStrategy;

import java.io.IOException;
import java.util.List;

import org.kohsuke.stapler.DataBoundConstructor;
import org.ovirt.jenkins.model.VM;

public class OVirtSlave extends Slave {

	final OVirtService service;
	final VM vm;

	@DataBoundConstructor
	public OVirtSlave(String name, String nodeDescription, String remoteFS,
			int numExecutors, Mode mode, String labelString,
			ComputerLauncher launcher, RetentionStrategy retentionStrategy,
			List<? extends NodeProperty<?>> nodeProperties,
			final OVirtService serrvice, final VM vm) throws FormException, IOException {
		super(name, nodeDescription, remoteFS, numExecutors, mode, labelString,
				launcher, retentionStrategy, nodeProperties);
		this.service = serrvice;
		this.vm = vm;
	}

	private static final long serialVersionUID = 4689480191162435035L;


	@Extension
	public static class OVirtSlaveDescriptor extends SlaveDescriptor {

		@Override
		public String getDisplayName() {
			return "oVirt slave";
		}

	}


	@Override
	public Computer createComputer() {
		return new OVirtComputer(this, vm.getId());
	}
}
